package com.hdy.splitNaturalNumber;

public class Solution {
    public Solution() {
    }

    public static void sol(int n) {
        int[] temp = new int[100];
        split(n, 1, 0, temp);
    }

    private static void split(int n, int i, int j, int[] temp) {
        while(i <= n / 2) {
            int ans = n - i;
            temp[j++] = i;
            temp[j] = ans;
            split(ans, i, j, temp);
            temp[j] = ans;
            print(temp);
            temp[j] = 0;
            --j;
            ++i;
        }

    }

    private static void print(int[] temp) {
        System.out.print(temp[0]);

        for(int i = 1; temp[i] != 0; ++i) {
            System.out.print("+" + temp[i]);
        }

        System.out.println();
    }
}
